<?php
require_once('../../auth/auth.php');

//get values from POST
	$title=$_POST['title'];        
	$first_name=$_POST['first_name'];    
 	$last_name=$_POST['last_name'];    
	$gender=$_POST['gender'];    
	$email_address=$_POST['email_address'];  
	$phone_number=$_POST['phone_number'];  
	$apt_number=$_POST['apt_number'];        
	$street_address=$_POST['street_address'];    
 	$city=$_POST['city'];  
 	$state=$_POST['state'];    
 	$zipcode=$_POST['zipcode']; 
 	
	$personalUpdate = !isset($_POST['id']);  	
 	
	if ($personalUpdate){
		 	$user_id = $_SESSION['SESS_USER_ID'];	
	} else {
			$user_id=$_POST['id'];	
	}
	

	
include 'db_Connect.php';
	
$user = "UPDATE User SET title='".$title
			."', first_name='".$first_name
			."', last_name='".$last_name
			."', gender='".$gender
			."', email_address='".$email_address
			."', phone_number='".$phone_number
			."', apt_number='".$apt_number
			."', street_address='".$street_address
			."', city='".$city
			."', state='".$state
			."', zipcode='".$zipcode
			."' WHERE user_id='".$user_id."'";
$result = mysql_query($user);	//user update executes

if($result){
	echo("<br>User update succeeded");
		if ($personalUpdate){
         $_SESSION['SESS_USER_TITLE'] = $title;
			$_SESSION['SESS_USER_FIRST_NAME'] = $first_name;
			$_SESSION['SESS_USER_LAST_NAME'] = $last_name;
		   header("Location:../profile.php");
		} else {
			header("Location:../adopterSummary.php?id=".$user_id);
		}
} else{
	echo("<br> User update failed");
}

include 'db_Close.php';
?>

